package com.yanqu.road.entity.activity.pawnshop;

import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.SplitHelper;
import com.yanqu.road.utils.range.RangeInt;
import com.yanqu.road.utils.string.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 当铺配置
 */
public class PawnshopConfig {

    private static Logger logger = LogManager.getLogger(PawnshopConfig.class.getName());

    private RandomHelper randomHelper = new RandomHelper();

    /**
     * 进行中的活动信息
     **/
    private ActivityInfo activityInfo = null;

    /**
     * 当铺配置<当铺等级，当铺配置>
     **/
    private Map<Integer, ConfPawnshop> confPawnshopMap = new HashMap<>();
    /**
     * 当铺员工配置<员工类型，<员工等级，员工配置>>
     **/
    private Map<Integer, Map<Integer, ConfPawnshopStaff>> confPawnshopStaffMap = new HashMap<>();
    /**
     * 当铺物件配置<goodsId，物件配置>
     **/
    private Map<Integer, ConfPawnshopItem> confPawnshopItemMap = new HashMap<>();
    /**
     * 当铺物件等级对应的权重<类型，<等级，<goodsId，权重>>>
     **/
    private Map<Integer, Map<Integer, Map<Integer, Integer>>> confItemWeightMap = new HashMap<>();

    private Map<Integer, ConfPawnshopEvent> confPawnshopEventMap;
    /**
     * 玉石状态范围
     */
    public List<RangeInt> gemstoneStatusRangeList = new ArrayList<>();
    public List<Integer> gemstoneStatusWeightList = new ArrayList<>();
    /**
     * 当铺物件等级配置<物件等级，物件等级配置>
     **/
    private Map<Integer, ConfPawnshopItemLv> confPawnshopItemLvMap = new HashMap<>();

    // 解析固定配置//////////////////////////////////////////////////////////////////////////////////////////
    /**
     * 体力初始值
     **/
    public int staminaInit = 0;
    /**
     * 体力上限值
     **/
    public int staminaMax = 0;
    /**
     * 体力每恢复1点需要的时间
     **/
    public int staminaTime = 0;
    /**
     * 体力每消耗1点增加的活动积分
     **/
    public int staminaScore = 0;
    /**
     * 体力恢复道具对应的物品ID
     **/
    public int staminaGoodsId = 0;
    /**
     * 当铺积分对应的物品ID
     **/
    public int scoreGoodsId = 0;
    /**
     * 初始赠送的4件固定物品ID
     **/
    public List<String> goodsIdInitList = new ArrayList<>();
    /**
     * 每接待3个顾客增加一天经营天数
     **/
    public int receptionDay = 0;

    /**
     * 物件稀有度对应的修复/伪造消耗天数<稀有度，天数>
     **/
    public Map<Integer, Integer> rarityCostDayMap = new HashMap<>();
    /**
     * 物件稀有度对应的计算价格占比千分比<稀有度，价格占比>
     **/
    public Map<Integer, Integer> rarityPriceRateMap = new HashMap<>();
    /**
     * 伪造消耗天数
     */
    public Map<Integer, Integer> fakeCostDaysMap = new HashMap<>();

    /**
     * 物件状态对应的计算价格浮动范围<状态，价格浮动范围>
     **/
    public Map<Integer, RangeInt> statusPriceRangeMap = new HashMap<>();
    /**
     * 物件状态对应的是否可修复<状态，是否可修复>
     **/
    private Map<Integer, Boolean> statusIsRepairMap = new HashMap<>();
    /**
     * 物件状态对应的显示图片类型<状态，显示图片类型>
     **/
    public Map<Integer, Integer> statusIconTypeMap = new HashMap<>();

    /**
     * 物件伪造等级对应的赋予词条等级<伪造等级，词条等级上下限>
     **/
    public Map<Integer, List<Integer>> fakeAffixLvMap = new HashMap<>();

    /**
     * 假货被发现概率
     * 星级 概率
     */
    public Map<Integer, Integer> fakeSeeThroughWeightMap = new HashMap<>();

    /**
     * 物件词条类型对应的文本编号范围<词条类型，文本编号范围>
     **/
    public Map<Integer, RangeInt> affixSnRangeMap = new HashMap<>();
    /**
     * 物件形容词条附带概率千分比
     **/
    public int affix2Rate = 0;
    /**
     * 物件事件词条等级对应的加成效果千分比<事件词条等级，加成效果>
     **/
    public Map<Integer, Integer> affixEventEffectMap = new HashMap<>();
    /**
     * 物件事件词条的权重
     **/
    public List<Integer> affixEventWeightList = new ArrayList<>();
    /**
     * 物件人物词条等级对应的效果千分比<人物词条等级，加成效果>
     **/
    public Map<Integer, Integer> affixPersonalEffectMap = new HashMap<>();
    /**
     * 物件人物词条的权重
     **/
    public List<Integer> affixPersonalWeightList = new ArrayList<>();

    /**
     * 事件NPC形象列表
     **/
    public List<String> npcIconList = new ArrayList<>();
    /**
     * 事件NPC形象权重
     **/
    public List<Integer> npcWeightList = new ArrayList<>();

    /**
     * 事件触发权重列表
     **/
    public List<Integer> eventWeightList = new ArrayList<>();

    /**
     * 时事初始概率
     **/
    private int politicsStartDay;
    /**
     * 时事初始概率
     **/
    private int politicsDefaultRate;
    /**
     * 时事累加概率
     **/
    private int politicsAddRate;

    // ==== 购买事件
    /**
     * 购买假货事件购买估价的千分比
     **/
    public int eventBuyFakeBuyRate;


    /**
     * 正常购买的概率
     */
    public int buyNormalRate;

    //===== 售卖事件 ====

    /**
     * 售卖假货事件购买估价的千分比
     **/
    public int eventSellFakeBuyRate;
    /**
     * 售卖假货成功概率
     */
    public int sellEventFakeSuccessRate;


    /**
     * 售卖事件权重翻倍参数
     */
    public int sellEventWeightDouble;


    //===== 典当 ====
    /**
     * 典当事件购买估价的千分比
     **/
    public int eventHockBuyRate;
    /**
     * 初始仙剑币
     */
    public int initCoin;

    private int hockDays;       //典当持续天数
    private int hockRedemptionRate;   //典当赎回概率
    private int hockInterest;         //典当利息
    public List<Integer> fakeStarFakeWeightList = new ArrayList<>();
    public List<Integer> fakeItemAffixWeightList = new ArrayList<>();

    public Map<Integer, List<Integer>> buyNpcParamMap = new HashMap<>();
    public Map<Integer, List<Integer>> buyPlayerParamMap = new HashMap<>();

    public Map<Integer, List<Integer>> sellNpcParamMap = new HashMap<>();
    public Map<Integer, List<Integer>> sellPlayerParamMap = new HashMap<>();

    public List<Integer> triggerParamList = new ArrayList<>();
    public List<Integer> triggerVipWeightParamList = new ArrayList<>();

    public int specialGemstoneId;
    public int specialGemstoneAddLv;

    /**
     * 默认构造体
     */
    public PawnshopConfig() {

    }

    /**
     * 活动配置
     *
     * @param activityInfo
     */
    public void setActivityInfo(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public int getActivityId() {
        return activityInfo == null ? 0 : activityInfo.getActivityId();
    }

    /**
     * 当铺配置
     *
     * @param confPawnshopList
     */
    public void setConfPawnshopList(List<ConfPawnshop> confPawnshopList) {
        /** 当铺配置<当铺等级，当铺配置> **/
        Map<Integer, ConfPawnshop> confPawnshopMap = new HashMap<>();
        for (ConfPawnshop conf : confPawnshopList) {
            confPawnshopMap.put(conf.getLevel(), conf);
        }
        this.confPawnshopMap = confPawnshopMap;
    }

    public Map<Integer, ConfPawnshop> getConfPawnshopMap() {
        return confPawnshopMap;
    }

    /**
     * 当铺员工配置
     *
     * @param confPawnshopStaffList
     */
    public void setConfPawnshopStaffList(List<ConfPawnshopStaff> confPawnshopStaffList) {
        /** 当铺员工配置<员工类型，<员工等级，员工配置>> **/
        Map<Integer, Map<Integer, ConfPawnshopStaff>> confPawnshopStaffMap = new HashMap<>();
        for (ConfPawnshopStaff conf : confPawnshopStaffList) {
            int type = conf.getType();
            Map<Integer, ConfPawnshopStaff> tmap = confPawnshopStaffMap.get(type);
            if (tmap == null) {
                tmap = new HashMap<>();
                confPawnshopStaffMap.put(type, tmap);
            }
            tmap.put(conf.getLevel(), conf);
        }
        this.confPawnshopStaffMap = confPawnshopStaffMap;
    }

    public Map<Integer, Map<Integer, ConfPawnshopStaff>> getConfPawnshopStaffMap() {
        return confPawnshopStaffMap;
    }

    /**
     * 当铺物件配置
     *
     * @param confPawnshopItemList
     */
    public void setConfPawnshopItemList(List<ConfPawnshopItem> confPawnshopItemList) {
        /** 当铺物件配置<goodsId，物件配置> **/
        Map<Integer, ConfPawnshopItem> confPawnshopItemMap = new HashMap<>();
        /** 当铺物件等级对应的权重<类型，<等级，<goodsId，权重>> **/
        Map<Integer, Map<Integer, Map<Integer, Integer>>> confItemWeightMap = new HashMap<>();

        for (ConfPawnshopItem conf : confPawnshopItemList) {
            int id = conf.getId();
            int type = conf.getType();
            confPawnshopItemMap.put(id, conf);
            // <等级，<goodsId，权重>
            Map<Integer, Map<Integer, Integer>> typeMap = confItemWeightMap.get(type);
            if (typeMap == null) {
                typeMap = new HashMap<>();
                confItemWeightMap.put(type, typeMap);
            }
            // 整理物件等级对应的物件权重
            int[] levelRange = SplitHelper.splitToInt(conf.getLevelRange(), ";");
            if (levelRange.length >= 2) {
                for (int lv = levelRange[0]; lv <= levelRange[1]; lv++) {
                    Map<Integer, Integer> wMap = typeMap.get(lv);
                    if (wMap == null) {
                        wMap = new HashMap<>();
                    }
                    wMap.put(id, conf.getWeight());
                    typeMap.put(lv, wMap);
                }
            }
        }
        this.confPawnshopItemMap = confPawnshopItemMap;
        this.confItemWeightMap = confItemWeightMap;
    }

    public Map<Integer, ConfPawnshopItem> getConfPawnshopItemMap() {
        return confPawnshopItemMap;
    }

    public ConfPawnshopItem getConfPawnshopItem(int goodsId) {
        return confPawnshopItemMap.get(goodsId);
    }

    public Map<Integer, Integer> getItemWeightMap(int type, int level) {
        Map<Integer, Integer> wMap = new HashMap<>();
        Map<Integer, Map<Integer, Integer>> typeMap = confItemWeightMap.get(type);
        if (typeMap != null) {
            wMap = typeMap.get(level);
        }
        return wMap;
    }

    /**
     * 当铺物件等级配置
     *
     * @param confPawnshopItemLvList
     */
    public void setConfPawnshopItemLvList(List<ConfPawnshopItemLv> confPawnshopItemLvList) {
        /** 当铺物件等级配置<物件等级，物件等级配置> **/
        Map<Integer, ConfPawnshopItemLv> confPawnshopItemLvMap = new HashMap<>();
        for (ConfPawnshopItemLv conf : confPawnshopItemLvList) {
            confPawnshopItemLvMap.put(conf.getLevel(), conf);
        }
        this.confPawnshopItemLvMap = confPawnshopItemLvMap;
    }

    public Map<Integer, ConfPawnshopItemLv> getConfPawnshopItemLvMap() {
        return confPawnshopItemLvMap;
    }

    /**
     * 解析参数
     *
     * @param configMap
     */
    public void parseParam(Map<String, ActivityConfig> configMap) {
        String value = "";
        /** 分隔符， **/
        String comma = ",";
        /** 分隔符; **/
        String semicolon = ";";
        /** 分隔符| **/
        String separator = "\\|";
        try {
            value = configMap.get("PAWNSHOP_STAMINA").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                int[] vals = SplitHelper.splitToIntSemicolon(value);
                staminaInit = vals[0];
                staminaMax = vals[1];
            }
            value = configMap.get("PAWNSHOP_STAMINA_SEC").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                staminaTime = Integer.parseInt(value.trim());
            }
            staminaScore = configMap.get("PWANSHOP_STAMINA_SCORE").getIntValue();
            staminaGoodsId = configMap.get("PAWNSHOP_STAMINA_GOODSID").getIntValue();
            scoreGoodsId = configMap.get("PAWNSHOP_SCORE_GOODSID").getIntValue();
            goodsIdInitList = StringUtils.stringToStringList(configMap.get("PAWNSHOP_GOOSID_INIT").getValue(), "\\|");
            receptionDay = configMap.get("PAWNSHOP_RECEPTION_DAY").getIntValue();

            // 物件相关配置///////////////////////////////////////////////////////////////////////////////////
            // 物件稀有度配置
            value = configMap.get("PAWNSHOP_ITEM_RARITY").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                List<String> list = StringUtils.stringToStringList(value, separator);
                for (int i = 0; i < list.size(); i++) {
                    int[] vals = SplitHelper.splitToIntSemicolon(list.get(i));
                    int index = i + 1;
                    rarityCostDayMap.put(index, vals[0]);
                    fakeCostDaysMap.put(index, vals[1]);
                    rarityPriceRateMap.put(index, vals[2]);
                }
            }
            // 物件状态配置
            value = configMap.get("PWANSHOP_ITEM_STATUS").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                String[] valueArr = value.split("\\|");
                int index = 1;
                for (String paramStr : valueArr) {
                    String[] paramArr = paramStr.split(";");
                    statusPriceRangeMap.put(index, new RangeInt(Integer.parseInt(paramArr[0]), Integer.parseInt(paramArr[1])));
                    statusIsRepairMap.put(index, "1".equals(paramArr[2]));
                    statusIconTypeMap.put(index, Integer.parseInt(paramArr[3]));
                    index++;
                }
            }
            // 物件伪造配置
            value = configMap.get("PWANSHOP_ITEM_FAKE").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                List<String> list = StringUtils.stringToStringList(value, "\\|");
                for (int i = 0; i < list.size(); i++) {
                    int index = i + 1;
                    fakeAffixLvMap.put(index, StringUtils.stringToIntegerList(list.get(i), ";"));
                }
            }

            value = configMap.get("PWANSHOP_ITEM_FAKE_EXPOSE").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                List<String> list = StringUtils.stringToStringList(value, "\\|");
                for (int i = 0; i < list.size(); i++) {
                    int weight = Integer.parseInt(list.get(i));
                    int index = i + 1;
                    fakeSeeThroughWeightMap.put(index, weight);
                }
            }

            // 词条相关配置///////////////////////////////////////////////////////////////////////////////////
            // 词条SN范围
            value = configMap.get("PWANSHOP_ITEM_AFFIX").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                int[] vals = SplitHelper.splitToIntSemicolon(value);
                for (int i = 0; i < vals.length; i++) {
                    affixSnRangeMap.put(i + 1, new RangeInt(1, vals[i]));
                }
            }
            affix2Rate = configMap.get("PWANSHOP_ITEM_AFFIX2_RATE").getIntValue();
            // 事件词条效果及权重
            value = configMap.get("PWANSHOP_ITEM_AFFIX3").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                List<String> list = StringUtils.stringToStringList(value, separator);
                for (int i = 0; i < list.size(); i++) {
                    int[] vals = SplitHelper.splitToIntSemicolon(list.get(i));
                    int index = i + 1;
                    affixEventEffectMap.put(index, vals[0]);
                    affixEventWeightList.add(vals[1]);
                }
            }
            // 人物词条效果及权重
            value = configMap.get("PWANSHOP_ITEM_AFFIX4").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                List<String> list = StringUtils.stringToStringList(value, separator);
                for (int i = 0; i < list.size(); i++) {
                    int[] vals = SplitHelper.splitToIntSemicolon(list.get(i));
                    int index = i + 1;
                    affixPersonalEffectMap.put(index, vals[0]);
                    affixPersonalWeightList.add(vals[1]);
                }
            }

            // NPC相关配置///////////////////////////////////////////////////////////////////////////////////
            value = configMap.get("PWANSHOP_NPC_ICON").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                List<String> list = StringUtils.stringToStringList(value, separator);
                for (int i = 0; i < list.size(); i++) {
                    String str = list.get(i);
                    String[] strs = str.split(semicolon);
                    npcIconList.add(strs[0]);
                    npcWeightList.add(Integer.parseInt(strs[1]));
                }
            }

            // 事件相关配置///////////////////////////////////////////////////////////////////////////////////
            value = configMap.get("PWANSHOP_EVENT").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                eventWeightList = StringUtils.stringToIntegerList(value, semicolon);
            }

            //时事配置
            value = configMap.get("PWANSHOP_POLITICS_CONFIG").getValue();
            if (!StringUtils.isNullOrEmpty(value)) {
                String[] paramArr = value.split(";");
                politicsStartDay = Integer.parseInt(paramArr[0]);
                politicsDefaultRate = Integer.parseInt(paramArr[1]);
                politicsAddRate = Integer.parseInt(paramArr[2]);
            }

            eventSellFakeBuyRate = configMap.get("PAWNSHOP_SELL_RECOGNITION_FAKE").getIntValue();
            sellEventFakeSuccessRate = configMap.get("PAWNSHOP_SELL_DERECOGNITION_FAKE").getIntValue();
            sellEventWeightDouble = configMap.get("PWANSHOP_SELL_DOUBLE").getIntValue();
            eventBuyFakeBuyRate = configMap.get("PAWNSHOP_BUY_FAKE_RATE").getIntValue();
            buyNormalRate = configMap.get("PAWNSHOP_BUY_NORMAL_RATE").getIntValue();

            //典当
            hockDays = configMap.get("PAWNSHOP_HOCK_DAYS").getIntValue();
            hockInterest = configMap.get("PAWNSHOP_HOCK_INTEREST").getIntValue();
            hockRedemptionRate = configMap.get("PAWNSHOP_HOCK_REDEMPTION_RATE").getIntValue();
            eventHockBuyRate = configMap.get("PAWNSHOP_HOCK_BUY_RATE").getIntValue();
            initCoin = configMap.get("PAWNSHOP_INIT_COIN").getIntValue();
            fakeStarFakeWeightList = configMap.get("PAWNSHOP_BUY_FAKE_STAR_RATE").getIntListValue("\\|");
            fakeItemAffixWeightList = configMap.get("PAWNSHOP_FAKE_ITEM_AFFIX_RATE").getIntListValue(";");

            value = configMap.get("PAWNSHOP_SELL_NPC_PARAM").getValue();
            String[] arr = value.split("\\|");
            for (int i = 0; i < arr.length; i++) {
                String s = arr[i];
                sellNpcParamMap.put(i + 1, StringUtils.stringToIntegerList(s, ";"));
            }

            value = configMap.get("PAWNSHOP_SELL_PLAYER_PARAM").getValue();
            arr = value.split("\\|");
            for (int i = 0; i < arr.length; i++) {
                String s = arr[i];
                sellPlayerParamMap.put(i + 1, StringUtils.stringToIntegerList(s, ";"));
            }
            value = configMap.get("PAWNSHOP_BUY_NPC_PARAM").getValue();
            arr = value.split("\\|");
            for (int i = 0; i < arr.length; i++) {
                String s = arr[i];
                buyNpcParamMap.put(i + 1, StringUtils.stringToIntegerList(s, ";"));
            }
            value = configMap.get("PAWNSHOP_BUY_PLAYER_PARAM").getValue();
            arr = value.split("\\|");
            for (int i = 0; i < arr.length; i++) {
                String s = arr[i];
                buyPlayerParamMap.put(i + 1, StringUtils.stringToIntegerList(s, ";"));
            }

            String specialEvent = configMap.get("PAWNSHOP_SPECIAL_EVENT").getValue();
            String[] split = specialEvent.split(";");
            specialGemstoneId = Integer.parseInt(split[0]);
            specialGemstoneAddLv = Integer.parseInt(split[1]);

            triggerParamList = configMap.get("PAWNSHOP_FAKE_ITEM_AFFIX_RATE_111").getIntListValue(";");
            triggerVipWeightParamList = configMap.get("PAWNSHOP_FAKE_ITEM_AFFIX_RATE_123").getIntListValue("\\|");

            String stoneStatusConfig = configMap.get("PAWNSHOP_STONE_STATUS_CONFIG").getValue();
            String[] strings = stoneStatusConfig.split("\\|");
            for (String s : strings) {
                String[] strArr = s.split(";");
                int minLv = Integer.parseInt(strArr[0]);
                int maxLv = Integer.parseInt(strArr[1]);
                int weight = Integer.parseInt(strArr[2]);
                gemstoneStatusRangeList.add(new RangeInt(minLv, maxLv));
                gemstoneStatusWeightList.add(weight);
            }

        } catch (Exception e) {
            logger.error("reload pawnshopconfig error", e);
        }
    }

    /**
     * 获取指定当铺配置
     *
     * @param level
     * @return
     */
    public ConfPawnshop getConfPawnshop(int level) {
        return confPawnshopMap.get(level);
    }

    /**
     * 获取升级所需财富
     *
     * @return
     */
    public long getPawnshopUpgradeMoney(int pawnshopLv) {
        return confPawnshopMap.get(pawnshopLv).getUpgradeMoney();
    }

    /**
     * 随机NPC形象
     *
     * @return
     */
    public String randomNpcIcon() {
        return (String) randomHelper.randomList(npcIconList);
    }

    /**
     * 生成送钱事件数据
     */
    public PawnshopMoney createMoneyJSON(int levelPS) {
        PawnshopMoney moneyJSON = new PawnshopMoney();
        ConfPawnshop confPawnshop = confPawnshopMap.get(levelPS);
        if (confPawnshop != null) {
            String range = confPawnshop.getMoneyRange();
            double value = 0;
            long minValue = 0;
            long maxValue = 0;
            String[] strArray = range.split(";");
            if (strArray.length >= 2) {
                minValue = Long.parseLong(strArray[0].trim());
                maxValue = Long.parseLong(strArray[1].trim());
                value = randomHelper.nextDouble(minValue, maxValue);
            }

            moneyJSON.setMoney((long) value);
            moneyJSON.setMoneyIcon(confPawnshop.getMoneyIcon());
        }
        return moneyJSON;
    }

    /**
     * 获取人物词条加成
     *
     * @return
     */
    public int getPersonalAffixAddition() {
        int totalWeight = 0;
        int lv = 0;
        for (Integer weight : affixPersonalWeightList) {
            totalWeight += weight;
        }
        int randomNum = randomHelper.next(0, totalWeight);
        for (int i = 1; i <= affixPersonalEffectMap.size(); i++) {
            Integer value = affixPersonalWeightList.get(i - 1);
            if (randomNum < value) {
                lv = i;
                break;
            }
            randomNum -= value;
        }
        return affixPersonalEffectMap.get(lv);
    }

    /**
     * 获取事件词条加成
     *
     * @return
     */
    public int getEventAffixAddition() {
        int totalWeight = 0;
        int lv = 0;
        for (Integer weight : affixEventWeightList) {
            totalWeight += weight;
        }
        int randomNum = randomHelper.next(0, totalWeight);
        for (int i = 1; i <= affixEventEffectMap.size(); i++) {
            Integer value = affixEventWeightList.get(i - 1);
            if (randomNum < value) {
                lv = i;
                break;
            }
            randomNum -= value;
        }
        return affixEventEffectMap.get(lv);
    }


    /**
     * 获取配置的取整值，最小1
     *
     * @param price
     * @return
     */
    private int getPriceRound(String price) {
        int round = 1;
        String[] strArray = price.split(";");
        if (strArray.length >= 3) {
            round = Integer.parseInt(strArray[2].trim());
            if (round < 1) {
                round = 1;
            }
        }
        return round;
    }

    /**
     * 根据物件等级获取随机一个物件Id
     *
     * @param type
     * @param level
     * @return
     */
    public int getGoodsId(int type, int level) {
        int id = 0;
        Map<Integer, Integer> wMap = getItemWeightMap(type, level);
        if (wMap != null) {
            id = RandomHelper.getRandomKeyByWeight(wMap);
        }
        return id;
    }

    /**
     * 根据当铺等级获取消耗体力值
     *
     * @param levelPS
     * @return
     */
    public int getStaminaCost(int levelPS) {
        int ret = Integer.MAX_VALUE;
        ConfPawnshop conf = confPawnshopMap.get(levelPS);
        if (conf != null) {
            ret = conf.getStaminaCost();
        }
        return ret;
    }

    /**
     * 获取员工配置
     *
     * @param staffType
     * @param staffLv
     * @return
     */
    public ConfPawnshopStaff getConfPawnshopStaff(int staffType, int staffLv) {
        Map<Integer, ConfPawnshopStaff> dataMap = confPawnshopStaffMap.get(staffType);
        if (null == dataMap) {
            return null;
        }
        return dataMap.get(staffLv);
    }

    /**
     * 获取稀有度消耗天数
     *
     * @param rarity
     * @return
     */
    public Integer getRarityCostDay(int rarity) {
        return rarityCostDayMap.get(rarity);
    }

    /**
     * 员工操作影响影响
     *
     * @param staffType
     * @param staffLv
     * @return
     */
    public int getStaffOpEffect(int staffType, int staffLv) {
        ConfPawnshopStaff confPawnshopStaff = getConfPawnshopStaff(staffType, staffLv);
        if (null != confPawnshopStaff) {
            return confPawnshopStaff.getParam1();
        }
        return 0;
    }

    /**
     * 操作物件是否超过限制
     *
     * @param opCount
     * @param staffType
     * @param staffLv
     * @return
     */
    public boolean isOpItemCountOver(int opCount, int staffType, int staffLv) {
        int limitCount = 0;
        ConfPawnshopStaff confPawnshopStaff = getConfPawnshopStaff(staffType, staffLv);
        if (null != confPawnshopStaff) {
            limitCount = confPawnshopStaff.getParam2();
        }
        return opCount >= limitCount;
    }

    public ConfPawnshopEvent getConfPawnshopEvent(int eventId) {
        return confPawnshopEventMap.get(eventId);
    }

    public Map<Integer, ConfPawnshopEvent> getConfPawnshopEventMap() {
        return confPawnshopEventMap;
    }

    public void setConfPawnshopEventMap(Map<Integer, ConfPawnshopEvent> confPawnshopEventMap) {
        this.confPawnshopEventMap = confPawnshopEventMap;
    }

    public int getReceptionDay() {
        return receptionDay;
    }

    public int getPoliticsStartDay() {
        return politicsStartDay;
    }

    public int getPoliticsDefaultRate() {
        return politicsDefaultRate;
    }

    public int getPoliticsAddRate() {
        return politicsAddRate;
    }

    /**
     * 物件状态是否可修复
     *
     * @param itemStatus
     * @return
     */
    public boolean itemStatusCanRepair(int itemStatus) {
        Boolean canRepair = statusIsRepairMap.get(itemStatus);
        if (null == canRepair) {
            return false;
        }
        return canRepair;
    }

    public int getHockDays() {
        return hockDays;
    }

    public int getHockRedemptionRate() {
        return hockRedemptionRate;
    }

    public int getHockInterest() {
        return hockInterest;
    }

    public int getItemMaxLvByItemType(int type) {
        Map<Integer, Map<Integer, Integer>> map = confItemWeightMap.get(type);
        int maxLv = 1;
        for (Integer lv : map.keySet()) {
            if (maxLv < lv) {
                maxLv = lv;
            }
        }
        return maxLv;
    }

    public boolean canTrigger(int dayPower, int triggerTimes) {
        int p1 = triggerParamList.get(0);
        int p2 = triggerParamList.get(1);
        int p3 = triggerParamList.get(2);
        int maxTimes = activityInfo.getServerIdList().size() * p3;
        if (triggerTimes >= maxTimes) {
            return false;
        }
        int firstNeedPower = p1 * staminaInit;
        int addValue = p2 * staminaInit;
        int value = firstNeedPower + addValue * triggerTimes;
        return dayPower >= value;
    }

    public int getMarkNum() {
        return triggerParamList.get(3);
    }

}
